package com.songcha.module_mine.ui.dialog

import android.content.Context
import android.graphics.Color
import android.graphics.LinearGradient
import android.graphics.Shader
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import com.songcha.library_business.util.MajiaBaoUtil
import com.songcha.library_common.ui.dialog.CustomDialog
import com.songcha.library_common.ui.view.CustomButton
import com.songcha.library_common.util.ScreenUtil
import com.songcha.library_common.util.dp2px
import com.songcha.module_mine.R

class GoldExchangeTipDialog(context:Context):CustomDialog(context) {
    private var mGoldSpend=0
    private var mObtainDay=0

    init {
        setDialogTitle("")
        setDialogMsg("")
        setShowBtn(false)
        setWidth(ScreenUtil.getScreenWidth())
        setHeight(320.dp2px())
        setRadius(0f)
        setBackgroundColor(Color.TRANSPARENT)
        setDimAmount(0f)
    }


    override fun hasView(): Boolean {
        return true
    }

    override fun getView(root: ViewGroup): View? {
        val view=LayoutInflater.from(context).inflate(R.layout.mine_dialog_gold_exchange_tip,root,false)

        val tvTitle=view.findViewById<TextView>(R.id.mine_tv_title)
        val majiaName = MajiaBaoUtil.getMajiaName()
        var titleStartColor = Color.parseColor("#B687F0")
        var titleEndColor = Color.parseColor("#9A7DFA")
        if(majiaName == "beike"){
            titleStartColor = Color.parseColor("#F67575")
            titleEndColor = Color.parseColor("#FA7DAC")
        }
        val shader =  LinearGradient(0f, 0f, 0f, tvTitle.textSize,titleStartColor , titleEndColor, Shader.TileMode.CLAMP)
        tvTitle.paint.shader = shader

        view.findViewById<ImageView>(R.id.mine_iv_close).setOnClickListener {
            dismiss()
        }

        view.findViewById<CustomButton>(R.id.mine_btn).setOnClickListener {
            dismiss()
        }

        view.findViewById<TextView>(R.id.mine_tv_gold_spend).apply {
            text="-"+mGoldSpend
        }
        view.findViewById<TextView>(R.id.mine_tv_obtain_day).apply {
            text="+"+mObtainDay
        }

        return view
    }

    fun setGoldSpend(gold:Int){
        mGoldSpend=gold
    }

    fun setObtainDay(day:Int){
        mObtainDay=day
    }

}